<?php
/**
 * 材料应用（品类）模型
 * (model)
 */
namespace App\Models\Product;

use Illuminate\Database\Eloquent\Model;

class ProductMaterialApplicationClassify extends Model{

    protected $table = 'product_material_classify';

    protected $guarded = [];

    const applicationType0 = 0;
    const applicationType1 = 1;
    const applicationType2 = 2;
    const applicationType3 = 3;
    const applicationType4 = 4;
    public static $applicationType = [
        self::applicationType0 => '无',
        self::applicationType1 => '睡眠系统',
        self::applicationType2 => '滑雪系统',
        self::applicationType3 => '冬季日常',
        self::applicationType4 => '徒步系统'
    ];

    public static function options($where = []){
        $query = $where ? self::query()->where(formatCondition($where)) : self::query();
        return $query->pluck('title','id');
    }

    public static function getModelById($id){
        return self::query()->find($id);
    }

    public static function getValueById($id,$field){
        return self::query()->where('id',$id)->value($field);
    }

}
